﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using PublicClass;
using PublicClass.Entity;
using S.RBAC.Domain.Dto;
using S.RBAC.Domain.Model;
using S.RBAC.Read.Api.Application.Command.StaffCommand;

namespace S.RBAC.Read.Api.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class StaffInfoController : ControllerBase
    {
        protected readonly IMediator _mediator;

        public StaffInfoController(IMediator mediator)
        {
            _mediator = mediator;
        }

        /// <summary>
        /// 获取部门信息
        /// </summary>
        /// <returns></returns>
        //[HttpGet]
        //public IActionResult GetDepartment()
        //{
        //    //下拉列表值
        //    List<object> list = new List<object>();

        //    //循环生成数组
        //    foreach (var item in Enum.GetValues<Department>())
        //    {
        //        list.Add(new
        //        {
        //            name = item.ToString(),
        //            value = item
        //        });
        //    }

        //    return Ok(list);
        //}

        /// <summary>
        /// 获取员工信息
        /// </summary>
        /// <param name="command">查询条件</param>
        /// <returns></returns>
        [HttpGet]
        public async Task<PageInfo<StaffDto>> GetAllStaff([FromQuery] StaffSelectCommand command)
        {
            return await _mediator.Send(command);
        }

        /// <summary>
        /// 获取单个员工信息
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<Staff> GetStaffInfo([FromQuery]StaffGetInfoCommand command)
        {
            return await _mediator.Send(command);
        }

        /// <summary>
        /// 获取员工Id及姓名
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<List<SelectList>> GetStaff([FromQuery]StaffGetAllCommand command)
        {
            return await _mediator.Send(command);
        }

        /// <summary>
        /// 获取姓名
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<StaffInfo> GetStaffName([FromQuery]StaffGetNameCommand command)
        {
            return await _mediator.Send(command);
        }

        /// <summary>
        /// 获取员工姓名列表
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<List<SelectList>> GetStaffNameInfo([FromQuery]StaffGetNameInfoCommand command)
        {
            return await _mediator.Send(command);
        }
    }
}
